<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once APPPATH . 'controllers/main.php';

/**
 * Контроллер отображения ссылки "смотреть видео онлайн"
 *
 * @package CoreFramework
 * @version 1.0
 * @author Gennadiy Kozlenko
 */
class Show_Video extends Main {
   
   /**
    * Title
    * @var string
    */
   var $title;
   
   /**
    * Original title
    * @var string
    */
   var $origTitle;
   
   /**
    * Year
    * @var int
    */
   var $year;
   
   /**
    * Конструктор класса
    *
    * @access public
    * @return Api
    */
   function Show_Video() {
      parent::Main();
      if (false !== $this->input->get('title')) {
         $this->title = $this->input->get('title');
      }
      if (false !== $this->input->get('orig_title')) {
         $this->origTitle = $this->input->get('orig_title');
      }
      if (false !== $this->input->get('year')) {
         $this->year = (int) $this->input->get('year');
      }
   }
   
   /**
    * Метод по умолчанию
    *
    * @access public
    */
   function index() {
      // Search video
      $this->db->select('id_video, title, orig_title, image, year, length, description')
         ->from('videos')
         ->where('status', 'active')
         ->where('num_torrents >', 0)
         ->where('title', $this->title)
         ->where('orig_title', $this->origTitle)
         ->where('year', $this->year);
      $query = $this->db->get();
      if (0 < $query->num_rows()) {
         $data = $query->row_array();
         $this->set_content($this->parser->parse('video/show_video.html', $data, true));
      }
      $this->set_layout('empty');
      $this->display();
   } // end index
   
   /**
    * Set output
    * @param string $output
    */
   function _output($output) {
      echo 'document.write("' . addslashes($output) . '");';
   }
   
}
